/**
 * 郭楠project
 * com.gn.micblog.controller
 * DataController.java
 * 创建人:TonyGuo 
 * 时间：2016年6月5日-上午11:21:50 
 * 2016Tm公司-版权所有
 */
package com.gn.controller;

import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.gn.entity.AdminUser;
import com.gn.entity.R;
import com.gn.entity.TestEmp;
import com.gn.entity.User;
import com.gn.service.AdminUserService;
import com.gn.service.EmpService;
import com.gn.test.AdminUserTest;
import com.gn.util.CommonUtils;
import com.gn.util.IdUtils;

/**
 * 
 * DataController
 * 创建人:TonyGuo
 * 时间：2016年6月5日-上午11:21:50 
 * @version 1.0.0
 * 
 */
@RestController
@RequestMapping("/rest/")
public class EmpController {
	Logger logger = LoggerFactory.getLogger(EmpController.class);
	@Resource
	EmpService empService;
	
	/**
	 * add
	 * @param user
	 */
	@RequestMapping(value="emp.add",method=RequestMethod.GET)
	public String addUser(HttpServletRequest req,TestEmp emp){
			emp.setStatus("no_del");
			empService.addEmp(emp);
		return "add_ok";
	}
	
	@RequestMapping(value="emp.update",method=RequestMethod.GET)
	public String updateUser(HttpServletRequest req,TestEmp emp){
		TestEmp e =	empService.findEmp(emp.getSalary());
			empService.update(emp);
		return "update_ok";
	}
	
	@RequestMapping(value="emp.get",method=RequestMethod.GET)
	public TestEmp getUser(HttpServletRequest req,@RequestParam("id") String id){
		TestEmp e=	empService.findEmp(id);
		return e;
	}
	
	@RequestMapping(value="emp.del/{id}",method=RequestMethod.GET)
	public String delUser(HttpServletRequest req,@PathVariable("id") String id){
		empService.del(id);
		return "del_ok";
	}
	
	@RequestMapping(value="emp.all",method=RequestMethod.GET)
	public List<TestEmp> getAll(HttpServletRequest req){
		return empService.findAll();
	}
	
	@RequestMapping(value="emp.nodel.all",method=RequestMethod.GET)
	public List<TestEmp> getAllNodel(HttpServletRequest req){
		return empService.findNodel();
	}
	
	
}
